import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class project {
    public String mostCommonWord(String paragraph, String[] banned) {
        Map<String,Integer> map=new HashMap<>();
        Set<String> set=new HashSet<>();
        for(String str:banned){
            set.add(str);
        }
        char[] ch=paragraph.toCharArray();
        int len=ch.length;
        String ret=null;
        for(int i=0;i<len;){
            if(!Character.isLetter(ch[i])&&++i>=0){
                continue;
            }
            int j=i;
            while (j<len&&Character.isLetter(ch[j])){
                j++;
            }
            String s=paragraph.substring(i,j).toLowerCase();
            i=j+1;
            if(set.contains(s)){
                continue;
            }
            map.put(s,map.getOrDefault(s,0)+1);
            if(ret==null||map.get(ret)<map.get(s)){
                ret=s;
            }
        }
        return ret;
    }
}
